package B_DAO;

import icdwkang.EmpVO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import B_DB.B_ProjectDB;

public class Emp_DAO {

	private final String inserSQL = "insert into Employees values (emp_seq.nextval,?,?,?,?,?,?,?,?,?,?,?)";
	private final String deleteSQL = "delete from Employees where empno=?";

	public int insertEmp(EmpVO e) {
		Connection conn = null;
		PreparedStatement ps = null;
		
		int cnt = 0;
		try {
			conn = B_ProjectDB.openConn();
			ps = conn.prepareStatement(inserSQL);
			ps.setString(1, e.getEname());
			ps.setString(2, e.getBirth());
			ps.setString(3, e.getSsn());
			ps.setString(4, e.getPhone());
			ps.setString(5, e.getAddr());
			ps.setString(6, e.getSname());
			ps.setString(7, e.getDeptno());
			ps.setString(8, e.getHiredate());
			ps.setString(9, e.getMgr());
			ps.setString(10, e.getSal());
			ps.setString(11, e.getJob());
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			B_ProjectDB.closeConn(conn, ps, null);sp
			
		}
		return cnt;
	}

	public int deleteEmp(String empno) {
		Connection conn = null;
		PreparedStatement ps = null;
		int cnt = 0;
		try {
			conn = B_ProjectDB.openConn();
			ps = conn.prepareStatement(deleteSQL);
			ps.setString(1, empno);
			cnt = ps.executeUpdate();
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			B_ProjectDB.closeConn(conn, ps, null);
		}
		return cnt;
	}
}
